/*
 * Copyright 2018 JDCLOUD.COM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http:#www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * 京东云httpdns OpenAPI接口
 * 京东云httpdns OpenAPI接口
 *
 * OpenAPI spec version: v1
 * Contact: 
 *
 * NOTE: This class is auto generated by the jdcloud code generator program.
 */


using JDCloudSDK.Core.Auth;
using JDCloudSDK.Core.Client;
using JDCloudSDK.Core.Http;
using JDCloudSDK.Httpdns.Apis;
using JDCloudSDK.Httpdns.Model;
using System;
using System.Collections.Generic;
using System.Text;
#if NET40||NET35
#else
using System.Threading.Tasks;
#endif

namespace JDCloudSDK.Httpdns.Client
{
    /// <summary>
    ///  京东云httpdns OpenAPI接口
    ///  京东云httpdns OpenAPI接口
    ///  Httpdns Api 客户端
    ///</summary>
    public class HttpdnsClient : JdcloudClient
    {

        /// <summary>
        ///  默认私有构造函数
        /// </summary>
        private HttpdnsClient()
        {

        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="credentialsProvider">认证信息</param>
        /// <param name="httpRequestConfig">http 客户端配置信息</param>
        /// <param name="environment">sdk 环境配置信息</param>
        public HttpdnsClient(CredentialsProvider credentialsProvider, HttpRequestConfig httpRequestConfig,SDKEnvironment environment)
        {
            this.httpRequestConfig = httpRequestConfig;
            this.credentialsProvider = credentialsProvider;
            this.environment = environment;
        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="httpRequestConfig">http 客户端配置信息</param>
        /// <param name="credentialsProvider">认证信息</param>
        public HttpdnsClient(CredentialsProvider credentialsProvider,HttpRequestConfig httpRequestConfig)
        {
            this.httpRequestConfig = httpRequestConfig;
            this.credentialsProvider = credentialsProvider;
        }

        /// <summary>
        /// 默认构造函数，
        /// 注意如果使用此方法 httpRequestConfig 使用的http 请求 schema 为Https
        /// </summary>
        /// <param name="credentialsProvider">认证信息</param>
        public HttpdnsClient(CredentialsProvider credentialsProvider)
        {
            this.credentialsProvider = credentialsProvider;
        }

        /// <summary>
        ///  版本号 1.0.9
        ///</summary>
        public const string ClientVersion = "1.0.9";

        private const string apiVersion = "v1";
        private const string userAgentPrefix = "JdcloudSdkDotNet";
        private const string defaultEndpoint = "httpdns.jdcloud-api.com";
        private const string serviceName = "httpdns";
        private const string userAgent = userAgentPrefix + "/" + ClientVersion + " " + serviceName + "/" + apiVersion;


        private SDKEnvironment environment = new SDKEnvironment(defaultEndpoint);
        private CredentialsProvider credentialsProvider;
        private HttpRequestConfig httpRequestConfig;

        /// <summary>
        ///  获取证书信息
        ///</summary>
        public override CredentialsProvider CredentialsProvider   { get { return credentialsProvider; } }

        /// <summary>
        ///  获取http 客户端配置信息
        ///</summary>
        public override HttpRequestConfig HttpRequestConfig { get { return httpRequestConfig; } }

        /// <summary>
        ///  获取sdk环境配置信息
        ///</summary>
        public override SDKEnvironment SDKEnvironment { get { return environment; } }

        /// <summary>
        ///  获取用户自定义浏览器识别字符串
        ///</summary>
        public override string UserAgent { get { return userAgent; } }

        /// <summary>
        ///  获取服务名称
        ///</summary>
        public override string ServiceName { get { return serviceName; } }

        /// <summary>
        ///  获取版本号
        ///</summary>
        public override string Version { get { return apiVersion; } }



#if NET40||NET35
        /// <summary>
        ///  查询httpdns账户的基本信息
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetAccountInfoResponse GetAccountInfo(GetAccountInfoRequest request) {
            return  new GetAccountInfoExecutor().Client(this).Execute<GetAccountInfoResponse, GetAccountInfoResult, GetAccountInfoRequest>(request);
        }
#else
        /// <summary>
        ///  查询httpdns账户的基本信息
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetAccountInfoResponse> GetAccountInfo(GetAccountInfoRequest request) {
            return await new GetAccountInfoExecutor().Client(this).Execute<GetAccountInfoResponse, GetAccountInfoResult, GetAccountInfoRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  添加域名。&lt;br&gt;
        /// 可以添加顶级域名除外的多级域名。
        /// 
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public AddDomainsResponse AddDomains(AddDomainsRequest request) {
            return  new AddDomainsExecutor().Client(this).Execute<AddDomainsResponse, AddDomainsResult, AddDomainsRequest>(request);
        }
#else
        /// <summary>
        ///  添加域名。&lt;br&gt;
        /// 可以添加顶级域名除外的多级域名。
        /// 
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<AddDomainsResponse> AddDomains(AddDomainsRequest request) {
            return await new AddDomainsExecutor().Client(this).Execute<AddDomainsResponse, AddDomainsResult, AddDomainsRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  删除域名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public DelDomainsResponse DelDomains(DelDomainsRequest request) {
            return  new DelDomainsExecutor().Client(this).Execute<DelDomainsResponse, DelDomainsResult, DelDomainsRequest>(request);
        }
#else
        /// <summary>
        ///  删除域名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<DelDomainsResponse> DelDomains(DelDomainsRequest request) {
            return await new DelDomainsExecutor().Client(this).Execute<DelDomainsResponse, DelDomainsResult, DelDomainsRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  创建httpdns账户
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public CreateAccountResponse CreateAccount(CreateAccountRequest request) {
            return  new CreateAccountExecutor().Client(this).Execute<CreateAccountResponse, CreateAccountResult, CreateAccountRequest>(request);
        }
#else
        /// <summary>
        ///  创建httpdns账户
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<CreateAccountResponse> CreateAccount(CreateAccountRequest request) {
            return await new CreateAccountExecutor().Client(this).Execute<CreateAccountResponse, CreateAccountResult, CreateAccountRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询用户名下httpdns的账户ID
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetAccountIdResponse GetAccountId(GetAccountIdRequest request) {
            return  new GetAccountIdExecutor().Client(this).Execute<GetAccountIdResponse, GetAccountIdResult, GetAccountIdRequest>(request);
        }
#else
        /// <summary>
        ///  查询用户名下httpdns的账户ID
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetAccountIdResponse> GetAccountId(GetAccountIdRequest request) {
            return await new GetAccountIdExecutor().Client(this).Execute<GetAccountIdResponse, GetAccountIdResult, GetAccountIdRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  查询使用httpdns服务的域名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public GetDomainsResponse GetDomains(GetDomainsRequest request) {
            return  new GetDomainsExecutor().Client(this).Execute<GetDomainsResponse, GetDomainsResult, GetDomainsRequest>(request);
        }
#else
        /// <summary>
        ///  查询使用httpdns服务的域名
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<GetDomainsResponse> GetDomains(GetDomainsRequest request) {
            return await new GetDomainsExecutor().Client(this).Execute<GetDomainsResponse, GetDomainsResult, GetDomainsRequest>(request).ConfigureAwait(false);
        }
#endif
#if NET40||NET35
        /// <summary>
        ///  创建，启用，禁用httpdns服务密钥
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public OperateKeyResponse OperateKey(OperateKeyRequest request) {
            return  new OperateKeyExecutor().Client(this).Execute<OperateKeyResponse, OperateKeyResult, OperateKeyRequest>(request);
        }
#else
        /// <summary>
        ///  创建，启用，禁用httpdns服务密钥
        /// </summary>
        /// <param name="request">请求参数信息</param>
        /// <returns>请求结果信息</returns>
        public async Task<OperateKeyResponse> OperateKey(OperateKeyRequest request) {
            return await new OperateKeyExecutor().Client(this).Execute<OperateKeyResponse, OperateKeyResult, OperateKeyRequest>(request).ConfigureAwait(false);
        }
#endif

            /// <summary>
            ///  默认HttpdnsClient 构造器 接口
            ///</summary>
            public interface Builder
            {

                /// <summary>
                /// 设置认证信息参数
                /// </summary>
                /// <param name="provider">认证信息提供对象</param>
                /// <returns>httpdnsClient 构造器</returns>
                Builder CredentialsProvider(CredentialsProvider provider);

                /// <summary>
                /// 设置请求环境参数
                /// </summary>
                /// <param name="environment">环境参数信息</param>
                /// <returns>httpdnsClient 构造器</returns>
                Builder Environment(Core.Client.SDKEnvironment environment);

                /// <summary>
                /// http 请求配置信息
                /// </summary>
                /// <param name="config">http 请求配置信息</param>
                /// <returns>httpdnsClient 构造器</returns>
                Builder HttpRequestConfig(HttpRequestConfig config);

                /// <summary>
                ///  构造HttpdnsClient 对象
                ///</summary>
                HttpdnsClient Build();
            }

            /// <summary>
            ///  默认HttpdnsClient 构造器
            ///</summary>
            public class DefaultBuilder : Builder
            {
                /// <summary>
                ///  HttpdnsClient service client
                /// </summary>
                private  HttpdnsClient httpdnsClient;

                /// <summary>
                ///  默认HttpdnsClient 构造器构造对象
                ///</summary>
                public DefaultBuilder()
                {
                    httpdnsClient = new HttpdnsClient();
                }

                /// <summary>
                ///  构造HttpdnsClient 对象
                ///</summary>
                public HttpdnsClient Build()
                {
                    if (httpdnsClient.CredentialsProvider == null)
                    {
                        //if credentialsProvider not set, try load jdcloud global default  credentials provider
                        httpdnsClient.credentialsProvider = JdCloud.DefaultInstance.GetCredentialsProvider();
                        if (httpdnsClient.credentialsProvider == null)
                        {
                            throw new ArgumentNullException("HttpdnsClient build error: jdcloud credentials provider not set");
                        }
                    }
                    if (httpdnsClient.HttpRequestConfig == null)
                    {
                        httpdnsClient.httpRequestConfig = JdCloud.DefaultInstance.GetHttpRequestConfig();
                        if (httpdnsClient.httpRequestConfig == null)
                        {
                        throw new ArgumentNullException("HttpdnsClient build error: http request config not set");
                        }
                    }
                    return httpdnsClient;
                }

                /// <summary>
                /// 设置认证信息参数
                /// </summary>
                /// <param name="provider">认证信息提供对象</param>
                /// <returns>httpdnsClient 构造器</returns>
                public Builder CredentialsProvider(CredentialsProvider provider)
                {
                    httpdnsClient.credentialsProvider = provider;
                    return this;
                }

                /// <summary>
                /// 设置请求环境参数
                /// </summary>
                /// <param name="environment">环境参数信息</param>
                /// <returns>httpdnsClient 构造器</returns>
                public Builder Environment(SDKEnvironment environment)
                {
                    httpdnsClient.environment = environment;
                    return this;
                }

                /// <summary>
                /// http 请求配置信息
                /// </summary>
                /// <param name="config">http 请求配置信息</param>
                /// <returns>httpdnsClient 构造器</returns>
                public Builder HttpRequestConfig(HttpRequestConfig config)
                {
                    httpdnsClient.httpRequestConfig = config;
                    return this;
                }
            }
    }
}
